package gupao.concurrency.states;

public class ImmutableLinkTest {
    public static void main(String[] args) {
        ImmutableLink.Node<String> node = new ImmutableLink.Node<>("a", null);
        ImmutableLink<String> linkA = new ImmutableLink<>(node);
        linkA = linkA.addHeader(new ImmutableLink.Node("b",null));
        ImmutableLink.Node<String> h = linkA.getHead();
        while(h != null){
            System.out.println(h.getItem());
            h = h.getNext();
        }

        linkA = linkA.removeHeader();
        h = linkA.getHead();
        while(h != null){
            System.out.println(h.getItem());
            h = h.getNext();
        }
    }
}
